package com.xiejun.bio;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class SocketClient {
    public static void main(String[] args) throws IOException {
        // 创建Socket客户端，连接到本地9000端口
        Socket socket = new Socket("localhost", 9000);
        
        // 准备要发送的数据
        String message = "Hello from BIO Socket Client!";
        OutputStream outputStream = socket.getOutputStream();
        
        // 发送数据到服务端
        outputStream.write(message.getBytes());
        outputStream.flush();
        
        System.out.println("发送数据到服务端: " + message);
        
        // 关闭资源
        outputStream.close();
        socket.close();
    }
}